from dao import Dao
from model.city import City

class CityDao(Dao):
    def __init__(self):
        """Arguments:
            collection --- string the name of the collection
        """
        Dao.__init__(self, City)
        self.collection = 'cities'
            
    def insert(self, city):
        """Save the user object to collection
        Arguments:
            user --- The User Model object
        """
        if isinstance(city, City):
            # Insert except ID field, because ID will be automatically generated
            _dict = {}
            _dict['city'] = city.city;
            _dict['province'] = city.province;
            _dict['country'] = city.country;
            
            self.db.insert(self.collection, _dict)
    
    
